# DIALECT = 'mysql'
# DRIVER = 'pymysql'
# USERNAME = 'cloud'
# PASSWORD = 'zdQmmt!yHH7Oa4N24Yd%#fMRzV%VwT*onL4kJ@qi17jaNIjVtL'
# HOST = '47.93.162.110'
# PORT = '3306'
# DATABASE = '数据库名'
#
# # mysql 不会认识utf-8,而需要直接写成utf8
# SQLALCHEMY_DATABASE_URI = "{}+{}://{}:{}@{}:{}/{}?charset=utf8".format(DIALECT, DRIVER, USERNAME, PASSWORD, HOST, PORT,
#                                                                        DATABASE)
# SQLALCHEMY_TRACK_MODIFICATIONS = False
# SQLALCHEMY_ECHO = True
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
import pymysql

import app

pymysql.install_as_MySQLdb()


class Config(object):
    """配置参数"""
    # 设置连接数据库的URL
    user = 'cloud'
    password = 'zdQmmt!yHH7Oa4N24Yd%#fMRzV%VwT*onL4kJ@qi17jaNIjVtL'
    database = 'cloud'
    app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://%s:%s@47.93.162.110/%s' % (user, password, database)

    # 设置sqlalchemy自动更跟踪数据库
    SQLALCHEMY_TRACK_MODIFICATIONS = True

    # 查询时会显示原始SQL语句
    app.config['SQLALCHEMY_ECHO'] = True

    # 禁止自动提交数据处理
    app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = False


# 读取配置
app.config.from_object(Config)

# 创建数据库sqlalchemy工具对象
db = SQLAlchemy(app)


# class appUpdate(db.Model):
#     # 定义表名
#     __tablename__ = 'app_update'
#     # 定义字段
#     id = db.Column(db.Integer, primary_key=True, autoincrement=True)
#     type = db.Column(db.Integer, unique=True, index=True)
#     version = db.Column(db.String(64), unique=True)
#     version_int = db.Column(db.Integer)
#     is_power = db.Column(db.Integer)
#     url = db.Column(db.String(64), unique=True)
#     msg = db.Column(db.String(64), unique=True)
#     is_new = db.Column(db.Integer)
